package com.iot08.common.entity.admin;

import lombok.Data;
import org.springframework.data.annotation.Transient;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;

import java.io.Serializable;
import java.util.Date;

/**
 * @version 1.0
 * @Description: 系统用户实体
 * @author: Rock
 * @time: 2020/8/12 15:12
 */
@Data
@Document(collection = "sys_user")
public class SysUser implements Serializable {

    private static final long serialVersionUID = 1L;

    @Field("_id")
    private String id;
    /**
     * 登录账号
     */
    private String account;

    private String password;

    /**
     * 昵称
     */
    private String nickname;

    /**
     * 角色id
     */
    @Field("role_id")
    private String roleId;

    /**
     * 渠道归属id
     */
    @Field("channel_affiliation_id")
    private String channelAffiliationId;

    /**
     * 0=系统账号、1=渠道账号
     */
    private Integer type;

    /**
     * 0=启用，1=禁用
     */
    private Integer status;

    /**
     * 登录ip
     */
    private String ip;

    /**
     * 最后登录时间
     */
    @Field("last_login_time")
    private Date lastLoginTime;
    @Field("old_last_login_time")
    private Date oldLastLoginTime;

    private String remark;

    //每天可解绑设备的数量
    @Field("unbind_num")
    private Integer unbindNum;
    //记录今天解绑的数量
    @Field("today_unbind_num")
    private Integer todayUnbindNum;
    //记录今天的日期
    @Field("unbind_date")
    private String unbindDate;

    /**
     * 0=正常，1=删除
     */
    private Integer deleted;

    // 是谁创建的此账号 (userId)
    private String creator;

    @Field("create_time")
    private Date createTime;

    @Field("update_time")
    private Date updateTime;
    /**
     * 头像
     */
    private String avatar;

    //关联区域id
    @Field("channel_area_id")
    private String channelAreaId;

    //角色对象
    @Transient
    private SysRole role;

    //渠道归属对象
    @Transient
    private ChannelAffiliation channelAff;

    //区域关联对象
    @Transient
    private ChannelArea channelArea;

}
